home *** CD-ROM | disk | FTP | other *** search
- From jdc@naucse.cse.nau.edu Thu Mar 5 09:27:04 1992
- Return-Path: <jdc@naucse.cse.nau.edu>
- Received: from naucse.cse.nau.edu by ra-next.arc.nasa.gov (NeXT-1.0 (From Sendmail 5.52)/NeXT-1.0)
- id AA10634; Thu, 5 Mar 92 09:26:53 PST
- Received: by naucse.cse.nau.edu (5.65c/1.5-nau)
- id AA21540; Thu, 5 Mar 1992 10:32:37 -0700
- Message-Id: <199203051732.AA21540@naucse.cse.nau.edu>
- From: jdc@naucse.cse.nau.edu (John Campbell)
- Date: Thu, 5 Mar 1992 10:32:35 MST
- X-Mailer: Mail User's Shell (7.2.3 5/22/91)
- To: woo@ra-next.arc.nasa.gov
- Subject: gplotlib.shr4
- Status: R
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 4 (of 5)."
- # Contents: gsr.c
- # Wrapped by jdc@naucse.cse.nau.edu on Tue Feb 11 08:42:16 1992
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'gsr.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'gsr.c'\"
- else
- echo shar: Extracting \"'gsr.c'\" \(37808 characters\)
- sed "s/^X//" >'gsr.c' <<'END_OF_FILE'
- X#define GSR_OWNER
- X#include "gsr.h"
- X
- X/*-
- X gnuplot Graphics Support Routines: gsr.c
- X
- X This module provides graphics routines similar to those used to
- X implement gnuplot. These routines are based on (and require) the
- X gnuplot Graphics Terminal library (gterm.c).
- X-*/
- X
- Xvoid plot_impulses();
- Xvoid plot_lines();
- Xvoid plot_points();
- Xvoid plot_dots();
- Xvoid edge_intersect();
- XBOOLEAN two_edge_intersect();
- X
- X
- X#define inrange(z,min,max) \
- X((min<max) ? ((z>=min)&&(z<=max)) : ((z>=max)&&(z<=min)) )
- X
- X/* (DFK) Watch for cancellation error near zero on axes labels */
- X#define SIGNIF (0.01) /* less than one hundredth of a tic mark */
- X#define CheckZero(x,tic) (fabs(x) < ((tic) * SIGNIF) ? 0.0 : (x))
- X#define NearlyEqual(x,y,tic) (fabs((x)-(y)) < ((tic) * SIGNIF))
- X
- X/* (DFK) For some reason, the Sun386i compiler screws up with the CheckLog
- X * macro, so I write it as a function on that machine.
- X */
- X#ifndef sun386
- X/* (DFK) Use 10^x if logscale is in effect, else x */
- X#define CheckLog(log, x) ((log) ? pow(10., (x)) : (x))
- X#else
- Xstatic double CheckLog(log, x)
- X BOOLEAN log;
- X double x;
- X{
- X if (log)
- X return(pow(10., x));
- X else
- X return(x);
- X}
- X#endif /* sun386 */
- X
- X
- Xstatic double LogScale(coord, islog, what, axis)
- X double coord; /* the value */
- X BOOLEAN islog; /* is this axis in logscale? */
- X char *what; /* what is the coord for? */
- X char *axis; /* which axis is this for ("x" or "y")? */
- X{
- X if (islog) {
- X if (coord <= 0.0) {
- X char errbuf[100]; /* place to write error message */
- X (void) sprintf(errbuf,"%s has %s coord of %g; must be above 0 for log scale!",
- X what, axis, coord);
- X (*GTterm_tbl[GTterm].text)();
- X (void) fflush(GSRoutfile);
- X int_error(errbuf, NO_CARET);
- X } else
- X return(log10(coord));
- X } else {
- X return(coord);
- X }
- X return((double)NULL); /* shut lint up */
- X}
- X
- X/* borders of plotting area */
- X/* computed once on every call to do_plot */
- Xstatic boundary(scaling)
- X BOOLEAN scaling; /* TRUE if terminal is doing the scaling */
- X{
- X register struct termentry *t = >term_tbl[GTterm];
- X GSRxleft = (t->h_char)*12;
- X GSRxright = (scaling ? 1 : GTxsize) * (t->xmax) - (t->h_char)*2 - (t->h_tic);
- X GSRybot = (t->v_char)*5/2 + 1;
- X GSRytop = (scaling ? 1 : GTysize) * (t->ymax) - (t->v_char)*3/2 - 1;
- X}
- X
- X
- Xstatic double dbl_raise(x,y)
- Xdouble x;
- Xint y;
- X{
- Xregister int i;
- Xdouble val;
- X
- X val = 1.0;
- X for (i=0; i < abs(y); i++)
- X val *= x;
- X if (y < 0 ) return (1.0/val);
- X return(val);
- X}
- X
- X
- Xstatic double make_tics(tmin,tmax,logscale)
- Xdouble tmin,tmax;
- XBOOLEAN logscale;
- X{
- Xregister double xr,xnorm,tics,tic,l10;
- X
- X xr = fabs(tmin-tmax);
- X
- X l10 = log10(xr);
- X if (logscale) {
- X tic = dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
- X if (tic < 1.0)
- X tic = 1.0;
- X } else {
- X xnorm = pow(10.0,l10-(double)((l10 >= 0.0 ) ? (int)l10 : ((int)l10-1)));
- X if (xnorm <= 2)
- X tics = 0.2;
- X else if (xnorm <= 5)
- X tics = 0.5;
- X else tics = 1.0;
- X tic = tics * dbl_raise(10.0,(l10 >= 0.0 ) ? (int)l10 : ((int)l10-1));
- X }
- X return(tic);
- X}
- X
- X
- Xgsr_init (fp, min_x, max_x, min_y, max_y, auto_x, auto_y, log_x, log_y)
- XFILE *fp;
- Xdouble min_x, max_x;
- Xdouble min_y, max_y;
- XBOOLEAN auto_x, auto_y, log_x, log_y;
- X/*-
- X Initialize the internal variables used by the Gnuplot graphics support
- X routines. Note that this routine should be called at least once before
- X any plot and at least once after changing the terminal type.
- X
- X Parameters:
- X
- X fp: Output file pointer. This is stored as GSRoutfile (which is
- X the same as GToutfile) and is the stream where all the
- X output for the plot is written. If fp is different than
- X GSRoutfile then the old GSRoutfile is replaced with the
- X new fp. Note that the old fp is *not* closed, this is the
- X responsibility of the caller. If fp is NULL the old
- X GSRoutfile continues to be used.
- X
- X min_x: Minimum x value that you intend to plot (in your own units).
- X
- X max_x: Maximum x value that you intend to plot (in your own units).
- X
- X min_y: Minimum y value that you intend to plot (in your own units).
- X
- X max_y: Maximum y value that you intend to plot (in your own units).
- X
- X auto_x: Automatically adjust the x tics to a sensible round-off point.
- X
- X auto_y: Automatically adjust the y tics to a sensible round-off point.
- X
- X log_x: Prepare for a logarithmic scale in the x dimension.
- X
- X log_y: Prepare for a logarithmic scale in the y dimension.
- X
- X-*/
- X{
- Xregister struct termentry *t = >term_tbl[GTterm];
- Xregister int xl, yl;
- Xdouble xtemp, ytemp;
- Xstruct text_label *this_label;
- Xstruct arrow_def *this_arrow;
- XBOOLEAN scaling;
- X
- X/* Make sure a terminal has been selected. */
- X if (GTterm == 0) {
- X gt_init_terminal();
- X if (GTterm == 0) {
- X int_error ("GTterm is 0--have you defined the variable GNUTERM?");
- X }
- X }
- X
- X/* Take care of GSRoutfile. */
- X if (fp == NULL) {
- X if (GSRoutfile == NULL) {
- X int_error("GSRoutfile NULL--gsr_init needs a file pointer!",NO_CARET);
- X }
- X }
- X else {
- X GSRoutfile = fp;
- X }
- X
- X/* store these in variables global to this file */
- X/* otherwise, we have to pass them around a lot */
- X GSRxmin = min_x;
- X GSRxmax = max_x;
- X GSRymin = min_y;
- X GSRymax = max_y;
- X GSRlogx = log_x;
- X GSRlogy = log_y;
- X
- X/* SETUP RANGES, SCALES AND TIC PLACES */
- X GSRytic = make_tics(GSRymin,GSRymax,GSRlogy);
- X
- X if (auto_y) {
- X if (GSRymin < GSRymax) {
- X GSRymin = GSRytic * floor(GSRymin/GSRytic);
- X GSRymax = GSRytic * ceil(GSRymax/GSRytic);
- X }
- X else { /* reverse axis */
- X GSRymin = GSRytic * ceil(GSRymin/GSRytic);
- X GSRymax = GSRytic * floor(GSRymax/GSRytic);
- X }
- X }
- X
- X GSRxtic = make_tics(GSRxmin,GSRxmax,GSRlogx);
- X
- X if (auto_x) {
- X if (GSRxmin < GSRxmax) {
- X GSRxmin = GSRxtic * floor(GSRxmin/GSRxtic);
- X GSRxmax = GSRxtic * ceil(GSRxmax/GSRxtic);
- X } else {
- X GSRxmin = GSRxtic * ceil(GSRxmin/GSRxtic);
- X GSRxmax = GSRxtic * floor(GSRxmax/GSRxtic);
- X }
- X }
- X
- X/* This was GSRxmax == GSRxmin, but that caused an infinite loop once. */
- X if (fabs(GSRxmax - GSRxmin) < ZERO)
- X int_error("GSRxmin should not equal GSRxmax!",NO_CARET);
- X if (fabs(GSRymax - GSRymin) < ZERO)
- X int_error("GSRymin should not equal GSRymax!",NO_CARET);
- X
- X/* INITIALIZE TERMINAL */
- X if (!GTterm_init) {
- X (*t->init)();
- X GTterm_init = TRUE;
- X }
- X scaling = (*t->scale)(GTxsize, GTysize);
- X
- X /* now compute boundary for plot (GSRxleft, GSRxright, GSRytop, GSRybot) */
- X boundary(scaling);
- X
- X/* SCALE FACTORS (gsr_map_x & y will now be ready to use) */
- X GSRyscale = (GSRytop - GSRybot)/(GSRymax - GSRymin);
- X GSRxscale = (GSRxright - GSRxleft)/(GSRxmax - GSRxmin);
- X}
- X
- Xgsr_graphics()
- X/*-
- X Routine to call the proper terminal t->graphics() routine. This
- X should be called prior to trying to draw anything on the graphics
- X terminal.
- X-*/
- X{
- Xregister struct termentry *t = >term_tbl[GTterm];
- X
- X (*t->graphics)();
- X}
- X
- X
- Xgsr_reset_terminal ()
- X/*-
- X Do what has to be done to reset the terminal after we are all
- X done plotting. (Mostly just call (*t->reset).)
- X-*/
- X{
- X struct termentry *t = >term_tbl[GTterm];
- X
- X (*t->reset)();
- X#ifdef VMS
- X vms_reset();
- X#endif
- X}
- X
- X
- Xgsr_draw_axis (xloc, yloc, visible)
- Xdouble xloc, yloc;
- Xint visible;
- X/*-
- X Routine to draw axis lines (with linetype -1). A horizontal line
- X will be drawn at xloc and a vertical line at yloc. Normal usage
- X is for xloc and yloc to be 0.0 Note that the yloc value is also
- X used as the line to draw impulses on for plotting IMPULSE style
- X curves. If ``visible'' is 0 then the lines won't be drawn, but
- X GSRxaxis_y will be computed and saved for use with IMPULSE plots.
- X
- X Parameters:
- X
- X xloc: Location (in user coordinates) of x axis line.
- X
- X yloc: Location (in user coordinates) of y axis line.
- X
- X visible: 0 - neither axis is drawn,
- X 1 - x axis only is drawn,
- X 2 - y axis only is drawn,
- X 3 - both axis are drawn.
- X
- X-*/
- X{
- X/* DRAW AXES */
- Xregister struct termentry *t = >term_tbl[GTterm];
- Xregister int xaxis_y, yaxis_x;
- X
- X/* Do we need to store linetype between each of these? */
- X xaxis_y = gsr_map_y(xloc);
- X yaxis_x = gsr_map_x(yloc);
- X
- X if (visible)
- X (*t->linetype)(-1); /* axis line type */
- X
- X if (xaxis_y < GSRybot)
- X xaxis_y = GSRybot; /* save for impulse plotting */
- X else if (xaxis_y >= GSRytop)
- X xaxis_y = GSRytop ;
- X else if ((visible & 1) && !GSRlogy) {
- X (*t->move)(GSRxleft,xaxis_y);
- X (*t->vector)(GSRxright,xaxis_y);
- X }
- X
- X if ((visible & 2) && !GSRlogx &&
- X yaxis_x >= GSRxleft && yaxis_x < GSRxright ) {
- X (*t->move)(yaxis_x,GSRybot);
- X (*t->vector)(yaxis_x,GSRytop);
- X }
- X GSRxaxis_y = xaxis_y;
- X}
- X
- X
- Xgsr_set_tic_format (xformat, yformat)
- Xchar *xformat, *yformat;
- X/*-
- X Routine to change the x and y tic mark formats (GSRxformat and GSRyformat)
- X the default for both is "%g".
- X
- X Parameter:
- X
- X xformat: Pointer to new sprintf GSRxformat string;
- X
- X yformat: Pointer to new sprintf GSRyformat string;
- X-*/
- X{
- X GSRxformat = xformat;
- X GSRyformat = yformat;
- X}
- X
- X
- Xgsr_draw_tics (xtics, xgrid, xtic_in, ytics, ygrid, ytic_in)
- Xint xtics, xgrid, xtic_in, ytics, ygrid, ytic_in;
- X/*-
- X Routine to draw and label the tic marks.
- X
- X Parameters:
- X
- X xtics: If 1 draw x axis tics, if 0 don't.
- X
- X xgrid: If 1 draw an x grid, if 0 don't.
- X
- X xtic_in: If 1 draw the x tics inward, if 0 don't.
- X
- X ytics: If 1 draw y axis tics, if 0 don't.
- X
- X ygrid: If 1 draw a y grid, if 0 don't.
- X
- X ytic_in: If 1 draw the y tics inward, if 0 don't.
- X-*/
- X{
- X#define TIC_COMPUTED 1
- Xregister struct termentry *t = >term_tbl[GTterm];
- Xint type=TIC_COMPUTED;
- X
- X/*
- X This routine can be improved by allowing for TIC_SERIES and TIC_USER
- X as is done in the main gnuplot package.
- X*/
- X
- X/* DRAW TICS */
- X (*t->linetype)(-2); /* border linetype */
- X
- X /* label y axis tics */
- X if (ytics) {
- X switch (type) {
- X case TIC_COMPUTED: {
- X if (GSRymin < GSRymax)
- X draw_ytics(GSRytic * floor(GSRymin/GSRytic),
- X GSRytic,
- X GSRytic * ceil(GSRymax/GSRytic), ygrid, ytic_in);
- X else
- X draw_ytics(GSRytic * floor(GSRymax/GSRytic),
- X GSRytic,
- X GSRytic * ceil(GSRymin/GSRytic), ygrid, ytic_in);
- X
- X break;
- X }
- X#ifdef NOTUSED_YET
- X case TIC_SERIES: {
- X draw_ytics(yticdef.def.series.start,
- X yticdef.def.series.incr,
- X yticdef.def.series.end, ygrid, ytic_in);
- X break;
- X }
- X case TIC_USER: {
- X draw_user_ytics(yticdef.def.user, ygrid, ytic_in);
- X break;
- X }
- X#endif
- X default: {
- X (*t->text)();
- X (void) fflush(GSRoutfile);
- X int_error("unknown tic type in yticdef in do_plot", NO_CARET);
- X break; /* NOTREACHED */
- X }
- X }
- X }
- X
- X /* label x axis tics */
- X if (xtics) {
- X switch (type) {
- X case TIC_COMPUTED: {
- X if (GSRxmin < GSRxmax)
- X draw_xtics(GSRxtic * floor(GSRxmin/GSRxtic),
- X GSRxtic,
- X GSRxtic * ceil(GSRxmax/GSRxtic), xgrid, xtic_in);
- X else
- X draw_xtics(GSRxtic * floor(GSRxmax/GSRxtic),
- X GSRxtic,
- X GSRxtic * ceil(GSRxmin/GSRxtic), xgrid, xtic_in);
- X
- X break;
- X }
- X#ifdef NOTUSED_YET
- X case TIC_SERIES: {
- X draw_xtics(xticdef.def.series.start,
- X xticdef.def.series.incr,
- X xticdef.def.series.end, xgrid, xtic_in);
- X break;
- X }
- X case TIC_USER: {
- X draw_user_xtics(xticdef.def.user, xgrid, xtic_in);
- X break;
- X }
- X#endif
- X default: {
- X (*t->text)();
- X (void) fflush(GSRoutfile);
- X int_error("unknown tic type in xticdef in do_plot", NO_CARET);
- X break; /* NOTREACHED */
- X }
- X }
- X }
- X}
- X
- X
- Xgsr_boundary ()
- X/*-
- X Routine to draw the boundary (border around the plot area).
- X-*/
- X{
- X
- X/* DRAW PLOT BORDER */
- Xregister struct termentry *t = >term_tbl[GTterm];
- X (*t->linetype)(-2); /* border linetype */
- X (*t->move)(GSRxleft,GSRybot);
- X (*t->vector)(GSRxright,GSRybot);
- X (*t->vector)(GSRxright,GSRytop);
- X (*t->vector)(GSRxleft,GSRytop);
- X (*t->vector)(GSRxleft,GSRybot);
- X}
- X
- Xgsr_ylabel (ylabel)
- Xchar *ylabel;
- X/*-
- X Routine to write a text lable for the y-axis. Some terminal
- X drivers will write this as vertically oriented text. LaTeX
- X will center the horizontal text on the left side of the plot.
- X
- X Parameter:
- X
- X ylabel: Text string to place as the y axis label.
- X-*/
- X{
- X/* PLACE YLABEL */
- Xregister struct termentry *t = >term_tbl[GTterm];
- X if (*ylabel != NULL) {
- X if ((*t->text_angle)(1)) {
- X if ((*t->justify_text)(CENTRE)) {
- X (*t->put_text)((t->v_char),
- X (GSRytop+GSRybot)/2, ylabel);
- X }
- X else {
- X (*t->put_text)((t->v_char),
- X (GSRytop+GSRybot)/2-(t->h_char)*strlen(ylabel)/2,
- X ylabel);
- X }
- X }
- X else {
- X (void)(*t->justify_text)(LEFT);
- X (*t->put_text)(0,GSRytop+(t->v_char), ylabel);
- X }
- X (void)(*t->text_angle)(0);
- X }
- X}
- X
- X
- Xgsr_xlabel (xlabel)
- Xchar *xlabel;
- X/*-
- X Routine to write a text label for the x-axis.
- X
- X Parameter:
- X
- X xlabel: Text string to place as the x axis label.
- X-*/
- X{
- X
- X/* PLACE XLABEL */
- Xregister struct termentry *t = >term_tbl[GTterm];
- X if (*xlabel != NULL) {
- X if ((*t->justify_text)(CENTRE))
- X (*t->put_text)( (GSRxleft+GSRxright)/2,
- X GSRybot-2*(t->v_char), xlabel);
- X else
- X (*t->put_text)( (GSRxleft+GSRxright)/2 - strlen(xlabel)*(t->h_char)/2,
- X GSRybot-2*(t->v_char), xlabel);
- X }
- X}
- X
- Xgsr_title (title)
- Xchar *title;
- X/*-
- X Routine to write a title at the top of the plot.
- X
- X Parameter:
- X
- X title: Text string to place as the title for the plot.
- X-*/
- X{
- X/* PLACE TITLE */
- Xregister struct termentry *t = >term_tbl[GTterm];
- X if (*title != NULL) {
- X if ((*t->justify_text)(CENTRE))
- X (*t->put_text)( (GSRxleft+GSRxright)/2,
- X GSRytop+(t->v_char), title);
- X else
- X (*t->put_text)( (GSRxleft+GSRxright)/2 - strlen(title)*(t->h_char)/2,
- X GSRytop+(t->v_char), title);
- X }
- X}
- X
- X
- Xgsr_label (x, y, text, justify, position)
- Xdouble x,y;
- Xchar *text;
- XBOOLEAN justify;
- Xint position;
- X/*-
- X Routine to place a label (text string) at (x,y) where (x,y) is in user
- X coordinates.
- X
- X Parameters:
- X
- X x: user coordinate x location for text string.
- X
- X y: user coordinate y location for text string.
- X
- X text: Text to plot at this location.
- X
- X justify: Flag indicating if text is to be justified in place:
- X 0 - don't justify
- X 1 - justify (if terminal device can do so).
- X
- X position: From gtplot.h, one of LEFT, CENTRE, RIGHT
- X-*/
- X{
- X/* PLACE LABELS */
- Xdouble xtemp, ytemp;
- Xregister struct termentry *t = >term_tbl[GTterm];
- X xtemp = LogScale(x, GSRlogx, "label", "x");
- X ytemp = LogScale(y, GSRlogy, "label", "y");
- X if ((*t->justify_text)(position)) {
- X (*t->put_text)(gsr_map_x(xtemp),gsr_map_y(ytemp),text);
- X }
- X else {
- X switch(position) {
- X case LEFT:
- X (*t->put_text)(gsr_map_x(xtemp),gsr_map_y(ytemp), text);
- X break;
- X case CENTRE:
- X (*t->put_text)(gsr_map_x(xtemp)-(t->h_char)*strlen(text)/2,
- X gsr_map_y(ytemp), text);
- X break;
- X case RIGHT:
- X (*t->put_text)(gsr_map_x(xtemp)-(t->h_char)*strlen(text),
- X gsr_map_y(ytemp), text);
- X break;
- X }
- X }
- X}
- X
- X
- Xgsr_arrow (start_x, start_y, end_x, end_y)
- Xdouble start_x, start_y, end_x, end_y;
- X/*-
- X Draw an arrow from (start_x,start_y) to (end_x,end_y).
- X
- X Parameters:
- X
- X start_x: starting x coordinate in user coordinates.
- X
- X start_y: starting y coordinate in user coordinates.
- X
- X end_x: ending x coordinate in user coordinates.
- X
- X end_y: ending y coordinate in user coordinates.
- X-*/
- X{
- X/* PLACE ARROWS */
- Xregister struct termentry *t = >term_tbl[GTterm];
- X int sx = gsr_map_x(LogScale(start_x, GSRlogx, "arrow", "x"));
- X int sy = gsr_map_y(LogScale(start_y, GSRlogy, "arrow", "y"));
- X int ex = gsr_map_x(LogScale(end_x, GSRlogx, "arrow", "x"));
- X int ey = gsr_map_y(LogScale(end_y, GSRlogy, "arrow", "y"));
- X
- X (*t->linetype)(0); /* arrow line type */
- X
- X (*t->arrow)(sx, sy, ex, ey);
- X}
- X
- X
- Xgsr_curve (style, points, npoints)
- Xint style, npoints;
- Xstruct coordinate *points;
- X/*-
- X Routine to draw the curve located in the array points to the device.
- X
- X Parameters:
- X
- X style: One of IMPULSES, LINES, POINTS, LINESPOINTS, or DOTS from
- X gtplot.h
- X
- X points: An array of npoints coordinates, where struct coordinate
- X is defined in gtplot.h.
- X
- X npoints: Number of points to plot out of the points array.
- X-*/
- X{
- Xregister struct termentry *t = >term_tbl[GTterm];
- X/* DRAW CURVES */
- X switch(style) {
- X case IMPULSES:
- X plot_impulses(points, npoints, GSRxaxis_y);
- X break;
- X case LINES:
- X plot_lines(points, npoints);
- X break;
- X case POINTS:
- X plot_points(points, npoints);
- X break;
- X case LINESPOINTS:
- X /* put lines */
- X plot_lines(points, npoints);
- X
- X /* put points */
- X plot_points(points, npoints);
- X break;
- X case DOTS:
- X plot_dots(points, npoints);
- X break;
- X default:
- X (*t->text)();
- X (void) fflush(GSRoutfile);
- X int_error("unknown style in gsr_points", NO_CARET);
- X break; /* NOTREACHED */
- X }
- X}
- X
- X
- Xgsr_text()
- X/*-
- X Routine to call the appropriate terminal _text() routine. This works
- X together with gsr_graphics() to go in and out of graphics mode:
- X
- X gsr_graphics(); ... plot routines ... gsr_text();
- X
- X On many terminal devices this must be called before any of the plot
- X will show up on the device.
- X-*/
- X{
- Xregister struct termentry *t = >term_tbl[GTterm];
- X
- X (*t->text)();
- X (void) fflush(GSRoutfile);
- X}
- X
- X
- Xgsr_line_point_type (line_type, point_type)
- X/*-
- X Routine to select (ahead of gsr_curve()) the line_type or point_type
- X that you wish to use.
- X
- X Parameters:
- X
- X line_type: The desired line type (from -2 - 12), the exact range
- X depends upon the term device in use.
- X
- X point_type: The desired point type (from -1 - 6) the exact range
- X depends upon the term device in use.
- X-*/
- X{
- X struct termentry *t = >term_tbl[GTterm];
- X
- X/* Record both requests. */
- X GSRpoint_type = point_type;
- X GSRline_type = line_type;
- X
- X/* Actually set the line_type request. */
- X (*t->linetype)(line_type);
- X}
- X
- X
- X#define OUTRANGE 0
- X#define INRANGE 1
- X#define UNDEFINED -1
- X
- X/* plot_impulses:
- X * Plot the curves in IMPULSES style
- X */
- Xstatic void
- Xplot_impulses(points, npoints, xaxis_y)
- X struct coordinate *points;
- X int xaxis_y;
- X{
- X int i;
- X int x,y;
- X int type;
- X struct termentry *t = >term_tbl[GTterm];
- X
- X for (i = 0; i < npoints; i++) {
- X type = inrange (points[i].x, GSRxmin, GSRxmax) &&
- X inrange (points[i].y, GSRymin, GSRymax);
- X switch (type) {
- X case INRANGE: {
- X x = gsr_map_x(points[i].x);
- X y = gsr_map_y(points[i].y);
- X break;
- X }
- X case OUTRANGE: {
- X if (!inrange(points[i].x, GSRxmin,GSRxmax))
- X continue;
- X x = gsr_map_x(points[i].x);
- X if ((GSRymin < GSRymax && points[i].y < GSRymin)
- X || (GSRymax < GSRymin && points[i].y > GSRymin))
- X y = gsr_map_y(GSRymin);
- X if ((GSRymin < GSRymax && points[i].y > GSRymax)
- X || (GSRymax<GSRymin && points[i].y < GSRymax))
- X y = gsr_map_y(GSRymax);
- X break;
- X }
- X default: /* just a safety */
- X case UNDEFINED: {
- X continue;
- X }
- X }
- X
- X (*t->move)(x,xaxis_y);
- X (*t->vector)(x,y);
- X }
- X
- X}
- X
- X/* plot_lines:
- X * Plot the curves in LINES style
- X */
- Xstatic void
- Xplot_lines(points, npoints)
- X struct coordinate *points;
- X int npoints;
- X{
- X int i; /* point index */
- X int x,y; /* point in terminal coordinates */
- X int type;
- X int clip_lines1 = 0, /* Not used yet. */
- X clip_lines2 = 0;
- X struct termentry *t = >term_tbl[GTterm];
- X enum coord_type prev = UNDEFINED; /* type of previous point */
- X double ex, ey; /* an edge point */
- X double lx[2], ly[2]; /* two edge points */
- X
- X for (i = 0; i < npoints; i++) {
- X type = inrange (points[i].x, GSRxmin, GSRxmax) &&
- X inrange (points[i].y, GSRymin, GSRymax);
- X switch (type) {
- X case INRANGE: {
- X x = gsr_map_x(points[i].x);
- X y = gsr_map_y(points[i].y);
- X
- X if (prev == INRANGE) {
- X (*t->vector)(x,y);
- X } else if (prev == OUTRANGE) {
- X /* from outrange to inrange */
- X if (!clip_lines1) {
- X (*t->move)(x,y);
- X } else {
- X edge_intersect(points, i, &ex, &ey);
- X (*t->move)(gsr_map_x(ex), gsr_map_y(ey));
- X (*t->vector)(x,y);
- X }
- X } else { /* prev == UNDEFINED */
- X (*t->move)(x,y);
- X (*t->vector)(x,y);
- X }
- X
- X break;
- X }
- X case OUTRANGE: {
- X if (prev == INRANGE) {
- X /* from inrange to outrange */
- X if (clip_lines1) {
- X edge_intersect(points, i, &ex, &ey);
- X (*t->vector)(gsr_map_x(ex), gsr_map_y(ey));
- X }
- X } else if (prev == OUTRANGE) {
- X /* from outrange to outrange */
- X if (clip_lines2) {
- X if (two_edge_intersect(points, i, lx, ly)) {
- X (*t->move)(gsr_map_x(lx[0]), gsr_map_y(ly[0]));
- X (*t->vector)(gsr_map_x(lx[1]), gsr_map_y(ly[1]));
- X }
- X }
- X }
- X break;
- X }
- X default: /* just a safety */
- X case UNDEFINED: {
- X break;
- X }
- X }
- X prev = type;
- X }
- X}
- X
- X/* plot_points:
- X * Plot the curves in POINTS style
- X */
- Xstatic void
- Xplot_points(points, npoints)
- X struct coordinate *points;
- X int npoints;
- X{
- X int i;
- X int x,y;
- X int type;
- X struct termentry *t = >term_tbl[GTterm];
- X
- X for (i = 0; i < npoints; i++) {
- X type = inrange (points[i].x, GSRxmin, GSRxmax) &&
- X inrange (points[i].y, GSRymin, GSRymax);
- X if (type == INRANGE) {
- X x = gsr_map_x(points[i].x);
- X y = gsr_map_y(points[i].y);
- X /* do clipping (was ...if necessary...) */
- X if ( x >= GSRxleft + t->h_tic && y >= GSRybot + t->v_tic
- X && x <= GSRxright - t->h_tic && y <= GSRytop - t->v_tic)
- X (*t->point)(x,y, GSRpoint_type);
- X }
- X }
- X}
- X
- X/* plot_dots:
- X * Plot the curves in DOTS style
- X */
- Xstatic void
- Xplot_dots(points, npoints)
- X struct coordinate *points;
- X int npoints;
- X{
- X int i;
- X int x,y;
- X int type;
- X struct termentry *t = >term_tbl[GTterm];
- X
- X for (i = 0; i < npoints; i++) {
- X type = inrange (points[i].x, GSRxmin, GSRxmax) &&
- X inrange (points[i].y, GSRymin, GSRymax);
- X if (type == INRANGE) {
- X x = gsr_map_x(points[i].x);
- X y = gsr_map_y(points[i].y);
- X /* point type -1 is a dot */
- X (*t->point)(x,y, -1);
- X }
- X }
- X}
- X
- X
- X/* single edge intersection algorithm */
- X/* Given two points, one inside and one outside the plot, return
- X * the point where an edge of the plot intersects the line segment defined
- X * by the two points.
- X */
- Xstatic void
- Xedge_intersect(points, i, ex, ey)
- X struct coordinate *points; /* the points array */
- X int i; /* line segment from point i-1 to point i */
- X double *ex, *ey; /* the point where it crosses an edge */
- X{
- X /* global xmin, xmax, ymin, xmax */
- X double ax = points[i-1].x;
- X double ay = points[i-1].y;
- X double bx = points[i].x;
- X double by = points[i].y;
- X double x, y; /* possible intersection point */
- X
- X if (by == ay) {
- X /* horizontal line */
- X /* assume inrange(by, GSRymin, GSRymax) */
- X *ey = by; /* == ay */
- X
- X if (inrange(GSRxmax, ax, bx))
- X *ex = GSRxmax;
- X else if (inrange(GSRxmin, ax, bx))
- X *ex = GSRxmin;
- X else {
- X (*GTterm_tbl[GTterm].text)();
- X (void) fflush(GSRoutfile);
- X int_error("error in edge_intersect", NO_CARET);
- X }
- X return;
- X } else if (bx == ax) {
- X /* vertical line */
- X /* assume inrange(bx, GSRxmin, GSRxmax) */
- X *ex = bx; /* == ax */
- X
- X if (inrange(GSRymax, ay, by))
- X *ey = GSRymax;
- X else if (inrange(GSRymin, ay, by))
- X *ey = GSRymin;
- X else {
- X (*GTterm_tbl[GTterm].text)();
- X (void) fflush(GSRoutfile);
- X int_error("error in edge_intersect", NO_CARET);
- X }
- X return;
- X }
- X
- X /* slanted line of some kind */
- X
- X /* does it intersect ymin edge */
- X if (inrange(GSRymin, ay, by) && GSRymin != ay && GSRymin != by) {
- X x = ax + (GSRymin-ay) * ((bx-ax) / (by-ay));
- X if (inrange(x, GSRxmin, GSRxmax)) {
- X *ex = x;
- X *ey = GSRymin;
- X return; /* yes */
- X }
- X }
- X
- X /* does it intersect ymax edge */
- X if (inrange(GSRymax, ay, by) && GSRymax != ay && GSRymax != by) {
- X x = ax + (GSRymax-ay) * ((bx-ax) / (by-ay));
- X if (inrange(x, GSRxmin, GSRxmax)) {
- X *ex = x;
- X *ey = GSRymax;
- X return; /* yes */
- X }
- X }
- X
- X /* does it intersect xmin edge */
- X if (inrange(GSRxmin, ax, bx) && GSRxmin != ax && GSRxmin != bx) {
- X y = ay + (GSRxmin-ax) * ((by-ay) / (bx-ax));
- X if (inrange(y, GSRymin, GSRymax)) {
- X *ex = GSRxmin;
- X *ey = y;
- X return;
- X }
- X }
- X
- X /* does it intersect xmax edge */
- X if (inrange(GSRxmax, ax, bx) && GSRxmax != ax && GSRxmax != bx) {
- X y = ay + (GSRxmax-ax) * ((by-ay) / (bx-ax));
- X if (inrange(y, GSRymin, GSRymax)) {
- X *ex = GSRxmax;
- X *ey = y;
- X return;
- X }
- X }
- X
- X /* It is possible for one or two of the [ab][xy] values to be -VERYLARGE.
- X * If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned
- X * FALSE above. Otherwise we fall through all the tests above.
- X * If two are -VERYLARGE, it is ax=ay=-VERYLARGE or bx=by=-VERYLARGE
- X * since either a or b must be INRANGE.
- X * Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
- X * Handle them carefully here. As yet we have no way for them to be
- X * +VERYLARGE.
- X */
- X if (ax == -VERYLARGE) {
- X if (ay != -VERYLARGE) {
- X *ex = min(GSRxmin, GSRxmax);
- X *ey = by;
- X return;
- X }
- X } else if (bx == -VERYLARGE) {
- X if (by != -VERYLARGE) {
- X *ex = min(GSRxmin, GSRxmax);
- X *ey = ay;
- X return;
- X }
- X } else if (ay == -VERYLARGE) {
- X /* note we know ax != -VERYLARGE */
- X *ex = bx;
- X *ey = min(GSRymin, GSRymax);
- X return;
- X } else if (by == -VERYLARGE) {
- X /* note we know bx != -VERYLARGE */
- X *ex = ax;
- X *ey = min(GSRymin, GSRymax);
- X return;
- X }
- X
- X /* If we reach here, then either one point is (-VERYLARGE,-VERYLARGE),
- X * or the inrange point is on the edge, and
- X * the line segment from the outrange point does not cross any
- X * other edges to get there. In either case, we return the inrange
- X * point as the 'edge' intersection point. This will basically draw
- X * line.
- X */
- X/* Had to change this--just guessing this is right. JDC */
- X if (points[i].x != -VERYLARGE) {
- X *ex = bx;
- X *ey = by;
- X } else {
- X *ex = ax;
- X *ey = ay;
- X }
- X return;
- X}
- X
- X/* double edge intersection algorithm */
- X/* Given two points, both outside the plot, return
- X * the points where an edge of the plot intersects the line segment defined
- X * by the two points. There may be zero, one, two, or an infinite number
- X * of intersection points. (One means an intersection at a corner, infinite
- X * means overlaying the edge itself). We return FALSE when there is nothing
- X * to draw (zero intersections), and TRUE when there is something to
- X * draw (the one-point case is a degenerate of the two-point case and we do
- X * not distinguish it - we draw it anyway).
- X */
- Xstatic BOOLEAN /* any intersection? */
- Xtwo_edge_intersect(points, i, lx, ly)
- X struct coordinate *points; /* the points array */
- X int i; /* line segment from point i-1 to point i */
- X double *lx, *ly; /* lx[2], ly[2]: points where it crosses edges */
- X{
- X /* global xmin, xmax, ymin, xmax */
- X double ax = points[i-1].x;
- X double ay = points[i-1].y;
- X double bx = points[i].x;
- X double by = points[i].y;
- X double x, y; /* possible intersection point */
- X BOOLEAN intersect = FALSE;
- X
- X if (by == ay) {
- X /* horizontal line */
- X /* y coord must be in range, and line must span both xmin and xmax */
- X /* note that spanning GSRxmin implies spanning GSRxmax */
- X if (inrange(by, GSRymin, GSRymax) && inrange(GSRxmin, ax, bx)) {
- X *lx++ = GSRxmin;
- X *ly++ = by;
- X *lx++ = GSRxmax;
- X *ly++ = by;
- X return(TRUE);
- X } else
- X return(FALSE);
- X } else if (bx == ax) {
- X /* vertical line */
- X /* x coord must be in range, and line must span both GSRymin and GSRymax */
- X /* note that spanning GSRymin implies spanning GSRymax */
- X if (inrange(bx, GSRxmin, GSRxmax) && inrange(GSRymin, ay, by)) {
- X *lx++ = bx;
- X *ly++ = GSRymin;
- X *lx++ = bx;
- X *ly++ = GSRymax;
- X return(TRUE);
- X } else
- X return(FALSE);
- X }
- X
- X /* slanted line of some kind */
- X /* there can be only zero or two intersections below */
- X
- X /* does it intersect GSRymin edge */
- X if (inrange(GSRymin, ay, by)) {
- X x = ax + (GSRymin-ay) * ((bx-ax) / (by-ay));
- X if (inrange(x, GSRxmin, GSRxmax)) {
- X *lx++ = x;
- X *ly++ = GSRymin;
- X intersect = TRUE;
- X }
- X }
- X
- X /* does it intersect GSRymax edge */
- X if (inrange(GSRymax, ay, by)) {
- X x = ax + (GSRymax-ay) * ((bx-ax) / (by-ay));
- X if (inrange(x, GSRxmin, GSRxmax)) {
- X *lx++ = x;
- X *ly++ = GSRymax;
- X intersect = TRUE;
- X }
- X }
- X
- X /* does it intersect GSRxmin edge */
- X if (inrange(GSRxmin, ax, bx)) {
- X y = ay + (GSRxmin-ax) * ((by-ay) / (bx-ax));
- X if (inrange(y, GSRymin, GSRymax)) {
- X *lx++ = GSRxmin;
- X *ly++ = y;
- X intersect = TRUE;
- X }
- X }
- X
- X /* does it intersect GSRxmax edge */
- X if (inrange(GSRxmax, ax, bx)) {
- X y = ay + (GSRxmax-ax) * ((by-ay) / (bx-ax));
- X if (inrange(y, GSRymin, GSRymax)) {
- X *lx++ = GSRxmax;
- X *ly++ = y;
- X intersect = TRUE;
- X }
- X }
- X
- X if (intersect)
- X return(TRUE);
- X
- X /* It is possible for one or more of the [ab][xy] values to be -VERYLARGE.
- X * If ax=bx=-VERYLARGE or ay=by=-VERYLARGE we have already returned
- X * FALSE above.
- X * Note that for ax=ay=-VERYLARGE or bx=by=-VERYLARGE we can do nothing.
- X * Otherwise we fall through all the tests above.
- X * Handle them carefully here. As yet we have no way for them to be +VERYLARGE.
- X */
- X if (ax == -VERYLARGE) {
- X if (ay != -VERYLARGE
- X && inrange(by, GSRymin, GSRymax) && inrange(GSRxmax, ax, bx)) {
- X *lx++ = GSRxmin;
- X *ly = by;
- X *lx++ = GSRxmax;
- X *ly = by;
- X intersect = TRUE;
- X }
- X } else if (bx == -VERYLARGE) {
- X if (by != -VERYLARGE
- X && inrange(ay, GSRymin, GSRymax) && inrange(GSRxmax, ax, bx)) {
- X *lx++ = GSRxmin;
- X *ly = ay;
- X *lx++ = GSRxmax;
- X *ly = ay;
- X intersect = TRUE;
- X }
- X } else if (ay == -VERYLARGE) {
- X /* note we know ax != -VERYLARGE */
- X if (inrange(bx, GSRxmin, GSRxmax) && inrange(GSRymax, ay, by)) {
- X *lx++ = bx;
- X *ly = GSRymin;
- X *lx++ = bx;
- X *ly = GSRymax;
- X intersect = TRUE;
- X }
- X } else if (by == -VERYLARGE) {
- X /* note we know bx != -VERYLARGE */
- X if (inrange(ax, GSRxmin, GSRxmax) && inrange(GSRymax, ay, by)) {
- X *lx++ = ax;
- X *ly = GSRymin;
- X *lx++ = ax;
- X *ly = GSRymax;
- X intersect = TRUE;
- X }
- X }
- X
- X return(intersect);
- X}
- X
- X/* DRAW_YTICS: draw a regular tic series, y axis */
- Xstatic draw_ytics(start, incr, end, ygrid, ytic_in)
- Xdouble start, incr, end; /* tic series definition */
- Xint ygrid, ytic_in;
- X /* assume start < end, incr > 0 */
- X{
- X double ticplace;
- X int ltic; /* for mini log tics */
- X double lticplace; /* for mini log tics */
- X double ticmin, ticmax; /* for checking if tic is almost inrange */
- X
- X if (end == VERYLARGE) /* for user-def series */
- X end = max(GSRymin,GSRymax);
- X
- X /* limit to right side of plot */
- X end = min(end, max(GSRymin,GSRymax));
- X
- X /* to allow for rounding errors */
- X ticmin = min(GSRymin,GSRymax) - SIGNIF*incr;
- X ticmax = max(GSRymin,GSRymax) + SIGNIF*incr;
- X end = end + SIGNIF*incr;
- X
- X for (ticplace = start; ticplace <= end; ticplace +=incr) {
- X if ( inrange(ticplace,ticmin,ticmax) )
- X ytick(ticplace, GSRyformat, incr, 1.0, ygrid, ytic_in);
- X if (GSRlogy && incr == 1.0) {
- X /* add mini-ticks to log scale ticmarks */
- X for (ltic = 2; ltic <= 9; ltic++) {
- X lticplace = ticplace+log10((double)ltic);
- X if ( inrange(lticplace,ticmin,ticmax) )
- X ytick(lticplace, (char *)NULL, incr, 0.5, ygrid, ytic_in);
- X }
- X }
- X }
- X}
- X
- X
- X/* DRAW_XTICS: draw a regular tic series, x axis */
- Xstatic draw_xtics(start, incr, end, xgrid, xtic_in)
- Xdouble start, incr, end; /* tic series definition */
- Xint xgrid, xtic_in;
- X /* assume start < end, incr > 0 */
- X{
- X double ticplace;
- X int ltic; /* for mini log tics */
- X double lticplace; /* for mini log tics */
- X double ticmin, ticmax; /* for checking if tic is almost inrange */
- X
- X if (end == VERYLARGE) /* for user-def series */
- X end = max(GSRxmin,GSRxmax);
- X
- X /* limit to right side of plot */
- X end = min(end, max(GSRxmin,GSRxmax));
- X
- X /* to allow for rounding errors */
- X ticmin = min(GSRxmin,GSRxmax) - SIGNIF*incr;
- X ticmax = max(GSRxmin,GSRxmax) + SIGNIF*incr;
- X end = end + SIGNIF*incr;
- X
- X for (ticplace = start; ticplace <= end; ticplace +=incr) {
- X if ( inrange(ticplace,ticmin,ticmax) )
- X xtick(ticplace, GSRxformat, incr, 1.0, xgrid, xtic_in);
- X if (GSRlogx && incr == 1.0) {
- X /* add mini-ticks to log scale ticmarks */
- X for (ltic = 2; ltic <= 9; ltic++) {
- X lticplace = ticplace+log10((double)ltic);
- X if ( inrange(lticplace,ticmin,ticmax) )
- X xtick(lticplace, (char *)NULL, incr, 0.5, xgrid, xtic_in);
- X }
- X }
- X }
- X}
- X
- X#ifdef NOTUSED_YET
- X/* DRAW_USER_YTICS: draw a user tic series, y axis */
- Xstatic draw_user_ytics(list, ygrid, ytic_in)
- Xstruct ticmark *list; /* list of tic marks */
- Xint ygrid, ytic_in;
- X{
- X double ticplace;
- X double incr = (GSRymax - GSRymin) / 10;
- X /* global GSRxmin, GSRxmax, xscale, GSRymin, GSRymax, yscale */
- X
- X while (list != NULL) {
- X ticplace = list->position;
- X if ( inrange(ticplace, GSRymin, GSRymax) /* in range */
- X || NearlyEqual(ticplace, GSRymin, incr) /* == GSRymin */
- X || NearlyEqual(ticplace, GSRymax, incr)) /* == GSRymax */
- X ytick(ticplace, list->label, incr, 1.0, ygrid, ytic_in);
- X
- X list = list->next;
- X }
- X}
- X#endif
- X
- X#ifdef NOTUSED_YET
- X/* DRAW_USER_XTICS: draw a user tic series, x axis */
- Xstatic draw_user_xtics(list, xgrid, xtic_in)
- Xstruct ticmark *list; /* list of tic marks */
- Xint xgrid, xtic_in;
- X{
- X double ticplace;
- X double incr = (GSRxmax - GSRxmin) / 10;
- X /* global GSRxmin, GSRxmax, xscale, GSRymin, GSRymax, yscale */
- X
- X while (list != NULL) {
- X ticplace = list->position;
- X if ( inrange(ticplace, GSRxmin, GSRxmax) /* in range */
- X || NearlyEqual(ticplace, GSRxmin, incr) /* == GSRxmin */
- X || NearlyEqual(ticplace, GSRxmax, incr)) /* == GSRxmax */
- X xtick(ticplace, list->label, incr, 1.0, xgrid, xtic_in);
- X
- X list = list->next;
- X }
- X}
- X#endif
- X
- X/* draw and label a y-axis ticmark */
- Xstatic ytick(place, text, spacing, ticscale, ygrid, ytic_in)
- Xdouble place; /* where on axis to put it */
- Xchar *text; /* optional text label */
- Xdouble spacing; /* something to use with checkzero */
- Xfloat ticscale; /* scale factor for tic mark (0..1] */
- Xint ygrid, ytic_in;
- X{
- X register struct termentry *t = >term_tbl[GTterm];
- X char ticlabel[101];
- X int ticsize = (int)((t->h_tic) * ticscale);
- X
- X place = CheckZero(place,spacing); /* to fix rounding error near zero */
- X if (ygrid) {
- X (*t->linetype)(-1); /* axis line type */
- X (*t->move)(GSRxleft, gsr_map_y(place));
- X (*t->vector)(GSRxright, gsr_map_y(place));
- X (*t->linetype)(-2); /* border linetype */
- X }
- X if (ytic_in) {
- X (*t->move)(GSRxleft, gsr_map_y(place));
- X (*t->vector)(GSRxleft + ticsize, gsr_map_y(place));
- X (*t->move)(GSRxright, gsr_map_y(place));
- X (*t->vector)(GSRxright - ticsize, gsr_map_y(place));
- X } else {
- X (*t->move)(GSRxleft, gsr_map_y(place));
- X (*t->vector)(GSRxleft - ticsize, gsr_map_y(place));
- X }
- X
- X /* label the ticmark */
- X if (text) {
- X (void) sprintf(ticlabel, text, CheckLog(GSRlogy, place));
- X if ((*t->justify_text)(RIGHT)) {
- X (*t->put_text)(GSRxleft-(t->h_char),
- X gsr_map_y(place), ticlabel);
- X } else {
- X (*t->put_text)(GSRxleft-(t->h_char)*(strlen(ticlabel)+1),
- X gsr_map_y(place), ticlabel);
- X }
- X }
- X}
- X
- X/* draw and label an x-axis ticmark */
- Xstatic xtick(place, text, spacing, ticscale, xgrid, xtic_in)
- Xdouble place; /* where on axis to put it */
- Xchar *text; /* optional text label */
- Xdouble spacing; /* something to use with checkzero */
- Xfloat ticscale; /* scale factor for tic mark (0..1] */
- Xint xgrid, xtic_in;
- X{
- X register struct termentry *t = >term_tbl[GTterm];
- X char ticlabel[101];
- X int ticsize = (int)((t->v_tic) * ticscale);
- X
- X place = CheckZero(place,spacing); /* to fix rounding error near zero */
- X if (xgrid) {
- X (*t->linetype)(-1); /* axis line type */
- X (*t->move)(gsr_map_x(place), GSRybot);
- X (*t->vector)(gsr_map_x(place), GSRytop);
- X (*t->linetype)(-2); /* border linetype */
- X }
- X if (xtic_in) {
- X (*t->move)(gsr_map_x(place), GSRybot);
- X (*t->vector)(gsr_map_x(place), GSRybot + ticsize);
- X (*t->move)(gsr_map_x(place), GSRytop);
- X (*t->vector)(gsr_map_x(place), GSRytop - ticsize);
- X } else {
- X (*t->move)(gsr_map_x(place), GSRybot);
- X (*t->vector)(gsr_map_x(place), GSRybot - ticsize);
- X }
- X
- X /* label the ticmark */
- X if (text) {
- X (void) sprintf(ticlabel, text, CheckLog(GSRlogx, place));
- X if ((*t->justify_text)(CENTRE)) {
- X (*t->put_text)(gsr_map_x(place),
- X GSRybot-(t->v_char), ticlabel);
- X } else {
- X (*t->put_text)(gsr_map_x(place)-(t->h_char)*strlen(ticlabel)/2,
- X GSRybot-(t->v_char), ticlabel);
- X }
- X }
- X}
- X
- Xstatic int_error(str,t_num)
- Xchar str[];
- Xint t_num;
- X/*
- X Routine to print an error and die. This is modified from the more
- X complex gnuplot version which longjumps back to the gnuplot prompt.
- X Note: NO_CARET is kept in some of the code above just to make these
- X routines look more like the originals. It isn't used at all here,
- X however.
- X*/
- X{
- X/* t_num is the token number, we don't have tokens... */
- X fprintf(stderr,"%s\n\n", str);
- X
- X#ifdef MAYBE_LATER
- X longjmp(env, TRUE); /* bail out to command line */
- X#else
- X exit(1);
- X#endif
- X}
- END_OF_FILE
- if test 37808 -ne `wc -c <'gsr.c'`; then
- echo shar: \"'gsr.c'\" unpacked with wrong size!
- fi
- # end of 'gsr.c'
- fi
- echo shar: End of archive 4 \(of 5\).
- cp /dev/null ark4isdone
- MISSING=""
- for I in 1 2 3 4 5 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 5 archives.
- rm -f ark[1-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
-
-